using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using clf.weighing.entity;


namespace weighing
{
    /// <summary>
    /// 磅房
    /// </summary>
    [Table(Name = "scale_house", Comment = "磅房")]
    public class ScaleHouseDao : BaseDao<ScaleHouse>
    {
        #region instance

        private static ScaleHouseDao? instance;
        public static ScaleHouseDao Instance => instance ??= new ScaleHouseDao();

        public override string GetTableName()
        {
            return TableName.scale_house.ToString();
        }
        #endregion



        public bool IsExist(ScaleHouse scaleHouse)
        {
            String condition = ScaleHouseField.name.ToString() + $" = '{scaleHouse.name}'";
            condition += $" and( {ScaleHouseField.company_id} = {App.CurrentCompanyVo.Id} )";
            String sql = SqlBuilder.GetSelectSqlWithSoftDeleteCondition(GetTableName(), "id", condition, null, null, null, 1, 0);
            var data = Sqlite.Select<MaterialCategory>(sql);
            return data.Count > 0;
        }

        public List<ScaleHouse> SelectList()
        {
            String condition = $"{ScaleHouseField.company_id} = {App.CurrentCompanyVo.Id}"; 
            String sql = SqlBuilder.GetSelectSqlWithSoftDeleteCondition(GetTableName(),null, condition);
            var data = Sqlite.Select<ScaleHouse>(sql);
            return data;
        }
    }
}
